<?php
/*
 * 清除缓存
 */
namespace app\admin\controller;

class Cache extends Comm
{
	public function clear(){
		cache(null); //系统自带双重清除
		$this->rmdirr(RUNTIME_PATH);  //自写清除
		return json(array('code' => 200, 'msg' => '系统缓存清除成功'));	
	}

        //递归删除缓存信息

    public function rmdirr($dirname)
    {
        if (!file_exists($dirname)) {
            return false;
        }
        if (is_file($dirname) || is_link($dirname)) {
            return unlink($dirname);
        }
        $dir = dir($dirname);
        if ($dir) {
            while (false !== $entry = $dir->read()) {
                if ($entry == '.' || $entry == '..') {
                    continue;
                }
                //递归
                $this->rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
            }
        }
        $dir->close();
        return rmdir($dirname);
    }

}
?>